package com.vf.admin.platform.service.impl;

import com.vf.admin.platform.dao.ElementDao;
import com.vf.admin.platform.dao.MenuDao;
import com.vf.admin.platform.dao.RoleMenuDao;
import com.vf.admin.platform.dao.RoleMenuElementDao;
import com.vf.admin.platform.entity.Menu;
import com.vf.admin.platform.service.MenuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MenuServiceImpl  implements MenuService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private MenuDao menuDao;
    @Autowired
    private ElementDao elementDao;
    @Autowired
    private RoleMenuElementDao roleMenuElementDao;
    @Autowired
    private RoleMenuDao roleMenuDao;


    @Override
    public void saveOrUpdate(Menu menu) {
        menuDao.saveOrUpdate(menu);
    }

    @Override
    public Menu get(Integer id) {
        return menuDao.get(id);
    }

    @Override
    public List<Menu> findList(Map<String, Object> paraMap) {
        return menuDao.findList(paraMap);
    }

    @Override
    public void del(int id) {
        menuDao.del(id);
        roleMenuDao.delByMenuId(id);
        elementDao.delByMenuId(id);
        roleMenuElementDao.delByMenuId(id);
    }
}
